
package info.mikrotubula.server;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.log4j.Logger;

public class ServerProperties {
   static Logger logger = Logger.getLogger(ServerProperties.class); 
   private static ServerProperties instance = null;
   private static Properties prop = null;
   protected ServerProperties() {
        prop = new Properties();
        InputStream fis;
        try {
            fis = ClassLoader.getSystemResourceAsStream("properties.xml");
            //fis = new FileInputStream();
            prop.loadFromXML(fis);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
   }
   public static ServerProperties getInstance() {
      if(instance == null) {
         instance = new ServerProperties();
      }
      return instance;
   }
   
   public static String getProperties(String key) {
      if(instance == null) {
         instance = new ServerProperties();
      }
      return prop.getProperty(key);
   }
}
